
import React, {Component} from 'react';
import { Image,  StatusBar,
  ScrollView
} from 'react-native';
import Swiper from '@/components/Swiper'
import SplitView from '@/components/SplitView'
import TipsView from '@/components/TipsView'
import GridView from './GridView'
import NewsList from './NewsList'
import DeviceStorage from '@/util/DeviceStorage'
import { setUserData } from '@/actions/user'
export default class Home extends Component{
  static navigationOptions = ({ navigation }) =>{
    return{
      title:'首页',
    }
  };
  componentWillMount = async() => {
    const user = await DeviceStorage.get('user')
    this.props.dispatch(setUserData(user))
  }
  render(){
    const imgList = [
      {
        img: {
          uri:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1563697916346&di=7d3977cba2882832a21e3636ed88c513&imgtype=0&src=http%3A%2F%2Fpic65.nipic.com%2Ffile%2F20150429%2F20318013_105209450000_2.jpg"
        }
      },
      {
        img: {
          uri:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1564292667&di=115d6fbb2d7e2d98429528b46b8bebd8&imgtype=jpg&er=1&src=http%3A%2F%2Fp5.zbjimg.com%2Ftask%2F2011-05%2F20%2F762496%2F4dd684820f8ad.jpg"
        }
      },
    ]
    console.log('index',this.props)
    return(
      
      <ScrollView showsVerticalScrollIndicator={false}>
        <StatusBar backgroundColor='#00B560'/>
        <Swiper imgList={imgList}/>
        <GridView />
        <SplitView height={5}/>
        <NewsList style={{flex:1}} {...this.props}/>
        <TipsView text="我是有底线的"/>
      </ScrollView>
    
    )
  }
  
}